﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace SachOnlineLibrary.DAL
{
    internal class HoaDonDAL
    {
        KetNoiDB ketnoidb;

        public HoaDonDAL()
        {
            ketnoidb = new KetNoiDB();
        }

        internal DataTable ThongKeSachBanChay()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select top 5 Sach.MaSach, TenSach, Sum(CHITIETPDH.SoLuong) as TongSoLuong from CHITIETPDH, Sach " +
                                "where CHITIETPDH.MaSach=Sach.MaSach group by Sach.MaSach, TenSach";
            DataTable dt = new DataTable();
            try
            {
                dt = ketnoidb.ExecuteQuery(cmd);
                return dt;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                return null;
            }
        }
    }
}
